<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
    <p id="time">时间：</p>
    <p id="date">日期：</p>
    <button></button>
</head>
<body>
<script>
    function time(){
        //.slice是取多少位数字
        //用"0"是将date转换为字符串类型
        hours = ("0" +  new Date().getHours()).slice(-2);
        minutes = ("0" + new Date().getMinutes()).slice(-2);
        seconds = ("0" + new Date().getSeconds()).slice(-2);
        document.getElementById("time").innerHTML = hours + ":" + minutes + ":" + seconds;
    }
    function date(){
        year=("0"+new Date().getFullYear()).slice(-4);
        months=("0"+new Date().getMonth());
        day=("0"+new Date().getDay());
        document.getElementById("date").innerHTML=year + "/" + months + "/" + day;
    }
    setInterval("time()", 1000);
    setInterval("date()",1000);
</script>
</body>
</html>